package avicit.bdp.dgs.metadata.dto;

import avicit.bdp.common.base.BaseDTO;
import avicit.platform6.core.annotation.log.FieldRemark;
import avicit.platform6.core.annotation.log.LogField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Objects;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.apache.commons.lang3.StringUtils;

/**
 * @author mayi 元模型
 */
@ApiModel(value = "MetadataModelDTO", description = "元模型")
@Table(name = "bdp_dgs_metadata_model")
public class MetadataModelDTO extends BaseDTO {

  /** 主键 */
  @Id
  @LogField
  @ApiModelProperty(value = "主键", name = "id")
  @FieldRemark(column = "id", field = "id", name = "主键")
  private String id;

  /** 元模型名称 */
  @LogField
  @ApiModelProperty(value = "元模型名称", name = "metadataModelName")
  @FieldRemark(column = "metadata_model_name", field = "metadataModelName", name = "元模型名称")
  private String metadataModelName;

  /** 试用数据源类型 */
  @LogField
  @ApiModelProperty(value = "试用数据源类型", name = "applyDatasourceType")
  @FieldRemark(column = "apply_datasource_type", field = "applyDatasourceType", name = "试用数据源类型")
  private String applyDatasourceType;

  /** 资源路径ID */
  @LogField
  @ApiModelProperty(value = "资源路径ID", name = "resourceId")
  @FieldRemark(column = "resource_Id", field = "resourceId", name = "资源路径ID")
  private String resourceId;

  /** 本地路径 */
  @LogField
  @ApiModelProperty(value = "本地路径", name = "fileLocalPath")
  @FieldRemark(column = "file_local_path", field = "fileLocalPath", name = "本地路径")
  private String fileLocalPath;

  /** 状态 */
  @LogField
  @ApiModelProperty(value = "状态", name = "status")
  @FieldRemark(column = "status", field = "status", name = "状态")
  private Integer status;

  @Transient
  @ApiModelProperty(value = "已应用库数量", name = "applyDatasourceNum")
  private Integer applyDatasourceNum;

  @Override
  public String getLogFormName() {
    if (StringUtils.isEmpty(super.logFormName)) {
      return "元数据模块";
    } else {
      return super.logFormName;
    }
  }

  @Override
  public String getLogTitle() {
    if (StringUtils.isEmpty(super.logTitle)) {
      return "元模型";
    } else {
      return super.logTitle;
    }
  }

  public String getId() {
    return id;
  }

  public void setId(String id) {
    this.id = id;
  }

  public String getMetadataModelName() {
    return metadataModelName;
  }

  public void setMetadataModelName(String metadataModelName) {
    this.metadataModelName = metadataModelName;
  }

  public String getApplyDatasourceType() {
    return applyDatasourceType;
  }

  public void setApplyDatasourceType(String applyDatasourceType) {
    this.applyDatasourceType = applyDatasourceType;
  }

  public Integer getApplyDatasourceNum() {
    return applyDatasourceNum;
  }

  public void setApplyDatasourceNum(Integer applyDatasourceNum) {
    this.applyDatasourceNum = applyDatasourceNum;
  }

  public String getResourceId() {
    return resourceId;
  }

  public void setResourceId(String resourceId) {
    this.resourceId = resourceId;
  }

  public String getFileLocalPath() {
    return fileLocalPath;
  }

  public void setFileLocalPath(String fileLocalPath) {
    this.fileLocalPath = fileLocalPath;
  }

  public Integer getStatus() {
    return status;
  }

  public void setStatus(Integer status) {
    this.status = status;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    MetadataModelDTO that = (MetadataModelDTO) o;
    return Objects.equals(getId(), that.getId())
        && Objects.equals(getMetadataModelName(), that.getMetadataModelName())
        && Objects.equals(getStatus(), that.getStatus())
        && Objects.equals(getApplyDatasourceType(), that.getApplyDatasourceType())
        && Objects.equals(getApplyDatasourceNum(), that.getApplyDatasourceNum());
  }

  @Override
  public int hashCode() {
    return Objects.hash(getId(), getMetadataModelName(), getApplyDatasourceType(), getStatus());
  }

  @Override
  public String toString() {
    return "MetadataModelDTO{"
        + "id='"
        + id
        + '\''
        + ", metadataModelName='"
        + metadataModelName
        + '\''
        + ", applyDatasourceType='"
        + applyDatasourceType
        + '\''
        + ", resourceId='"
        + resourceId
        + '\''
        + ", fileLocalPath='"
        + fileLocalPath
        + '\''
        + ", status="
        + status
        + ", applyDatasourceNum="
        + applyDatasourceNum
        + '}';
  }
}
